package com.hqd.ch03.bean;


import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;

public class AopTest {

    public void beforeTest(JoinPoint joinPoint) {
        System.out.println("beforeTest" + joinPoint);
    }

    public void beforeTestV19(JoinPoint joinPoint, String msg) {
        System.out.println("beforeTestV19-----" + msg);
    }

    public void afterTestV19(JoinPoint joinPoint, String msg) {
        System.out.println("afterTestV19-----" + msg);
    }

    public void afterTest() {
        System.out.println("afterTest");
    }

    public void afterReturnTestV19(JoinPoint joinPoint, int a, int b, int returning) {
        System.out.println("afterReturnTestV19-----" + a + "+" + b + "=" + returning);
    }

    public Object aroundTestV19(ProceedingJoinPoint joinPoint, String msg) throws Throwable {
        System.out.println("############ 环绕通知前，入参:" + msg + " ###############");
        Object proceed = joinPoint.proceed(joinPoint.getArgs());
        System.out.println("############ 环绕通知后，返回值：" + proceed + " ###############");
        return proceed;
    }

    public void afterThrowTestV19(Throwable ex) {
        System.out.println("afterThrowTestV19----- " + ex);
    }

    public void afterReturnTest() {
        System.out.println("afterReturnTest");
    }

    public Object aroundTest(ProceedingJoinPoint point) {
        System.out.println("beforeTest1");
        Object o = null;
        try {
            o = point.proceed();
        } catch (Throwable e) {
            e.printStackTrace();
        }
        System.out.println("afterTest1");
        return o;
    }
}
